{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="id" value="{$vo.id ?? ''}">
        <input type="hidden" name="pid" value="{$vo.pid ?? $Request.param.pid}">
        <input type="hidden" name="type" value="{$vo.type ?? $Request.param.type}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>标题：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="标题" name="title" value="{$vo.title ?? ''}"  datatype="*" nullmsg="请填写标题">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        {:widget('Ui/imageUpload',['image', '大图', $vo.image??'', true])}
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">内容：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <div id="content">
                    {foreach name="vo.content" item="v" key="k"}
                    <p>
                        <i>{$k+1}</i><input type="text" class="input-text" name="content[{$k}]" value="{$v}" />
                        <button type="button" class="btn btn-xs btn-danger deleteButton">&times;</button>
                    </p>
                    {/foreach}
                </div>
                <input type="text" value="" id="addText" class="input-text">
                <button type="button" class="btn btn-info" id="addButton">添加</button>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret){
                ajax_progress(ret);
            }
        });
        var index = {:intval(count($vo.content))};
        $('#addButton').click(function(){
            var value = $.trim($('#addText').val());
            var tpl = '<p><i>'+(index+1)+'</i><input type="text" class="input-text" name="content['+index+']" value="'+value+'"><button type="button" class="btn btn-xs btn-danger deleteButton">&times;</button></p>';
            $('#content').append(tpl);
            $('#addText').val('');
            index++;
        });
        $('body').on('click','.deleteButton',function(){
            $(this).closest('p').remove();
        });
    })
</script>
{/block}
